<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path;
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>教学成果分析-云校通</title>
<jsp:include page="/WEB-INF/page/common/_header.jsp"></jsp:include>
<script src="<%=basePath %>/js/picker.js"></script>
<script src="<%=basePath %>/js/select.js"></script>
</head>
<body ontouchstart>
	<div class="weui_tab tab-bottom">
		<div class="weui-header bg-blue">
	  		<div class="weui-header-left"> <a onclick="back()" href="javascript:" class="icon icon-109 f-white">返回</a> </div>
	    	<h1 class="weui-header-title">教师列表</h1>
	    	<div class="weui-header-right"> 
	    		<a href="<%=basePath %>/ls/teaching/fruit/report/detail/${user.teacher.id}" class="f-white">我的</a>
	    	</div>
		</div>
		<div class="searchbar_wrap"></div>
	    <div id="search-content" style="height: 100%;z-index: 10;position:relation;display: none;">
	       <div class="sb-content mb90" style="overflow:scroll;padding:0;">
	       		<div class="weui_cells mt0" id="searchList">
	       		</div>
	       </div>
	    </div>
		<div class="weui_tab_bd">
		    <div class="weui_cells mt0">
		    	<div class="weui_cell">
			    	<div class="weui_cell_hd weui_center_25">年级</div>
			    	<div class="weui_cell_hd weui_center_25">学科</div>
			    	<div class="weui_cell_hd weui_center_25">姓名</div>
			    	<div class="weui_cell_hd weui_center_25"></div>
			    </div>
		    </div>
	        <div class="weui_cells mt0 mb90" id="teacherList">
	            
	        </div>
		</div>
	</div>
<jsp:include page="/WEB-INF/page/common/_footer.jsp"></jsp:include>
<script type="text/javascript">
$(function() {
	$('.searchbar_wrap').searchBar({
		cancelText: "取消",
		searchText: '请输入教师姓名',
		onfocus: function(value) {
			$("#search-content").show();
		},
		onblur: function(value) {
		},
		input: function(value) {
			queryTeacher(value);
		},
		onsubmit: function(value) {
			queryTeacher(value);
		},
		oncancel: function() {
			$("#search-content").hide();
			$("#searchList").html('');
		},
		onclear: function() {
			$("#searchList").html('');
		}
	});
	queryTeacher(null);
})
var search = false;
function queryTeacher(name) {
	if(name != null) {
		if(!/^[\u4E00-\u9FA5]+$/.test(name)) return;
		if(search) return;
		search = true;
	}
	$.ajax({
		url: basePath + "/ls/teaching/fruit/report/teacherList",
		type: 'POST',
		dataType : "json",
		data: {
			teacherName: name
		},
		success: function(data) {
			search = false;
			if(data != null) {
				var html = '';
				for(var i in data) {
					var itm = data[i];
					html += '<div class="weui_cell f-14">\
						<div class="weui_cell_hd weui_center_25">'+itm.gradeText+'</div>\
		                <div class="weui_cell_hd weui_center_25">'+itm.subjectText+'</div>\
		                <div class="weui_cell_hd weui_center_25">'+itm.name+'</div>\
		                <div class="weui_cell_hd weui_center_25">\
		                	<a href="<%=basePath%>/ls/teaching/fruit/report/detail/'+itm.id+'">\
		                		<button class="weui_btn weui_btn_mini weui_btn_primary f-white">查看</button>\
		                	</a>\
		                </div>\
		            </div>';
				}
				if(name == null) {
					$("#teacherList").html(html);
				}else {
					$("#searchList").html(html);
				}
			}
		},
		error: function(data) {
		}
	});
}
</script>
</body>
</html>